'use strict';

const Controller = require('egg').Controller;

class UserpinglunController extends Controller {
  async pinglunsumbit() {
    let ziduan=this.ctx.request.query;
    // let uid= this.app.jwt.verify(ziduan.token, 'userid');
    // console.log(ziduan,111);
    let userinfosql=`SELECT touxiang,username FROM user WHERE uid=${ziduan.token}`;
    let userinfores=await this.app.mysql.query(userinfosql);
    if(userinfores[0]){
        let userimg=userinfores[0].touxiang;
        let username=userinfores[0].username;
        let insertinfo=`INSERT INTO pinlun (hid,factualaccounts,convenientlocation,clean,higher,eavcontext,createdtime,userimg,username) VALUES (${ziduan.hid},${ziduan.factualaccounts},${ziduan.convenientlocation},${ziduan.clean},${ziduan.higher},'${ziduan.eavcontext}','${ziduan.createdtime}','${userimg}','${username}')`;
        let insertinfores=await this.app.mysql.query(insertinfo);
        this.ctx.body={info:1989};
    }
  }
  async housetotalpinlun(){
    let hid=this.ctx.request.query.hid;
    this.ctx.service.datachuli.insertdata(hid);
    this.ctx.body={info:1989};
  }
  async houseshowpinlun(){
    let hid=this.ctx.request.query.hid;
    let pinlunfromshowsql=`SELECT *  FROM house_evaluate WHERE hid=${hid}`;
    let resarr=await this.app.mysql.query(pinlunfromshowsql);
    this.ctx.body={resarr};
  }
  async pinglunxiangqing(){
    let hid=this.ctx.request.query.hid;
    let sql=`SELECT userimg,username,createdtime,eavcontext  FROM pinlun WHERE hid=${hid}`;
    let sqlres=await this.app.mysql.query(sql);
    this.ctx.body={sqlres};
  }
}

module.exports = UserpinglunController;